#include <bits/stdc++.h>
#define uint unsigned long long
#define sint long long
using namespace std;
struct car{
	int startPos, speed, plusSpeed;
};
int n, m, limit, maxScore;

bool isNotOK(int targetPos, car k){
	return sqrt(k.speed * 1ll * k.speed + 2ll * k.plusSpeed * (targetPos - k.startPos)) > limit;
}
car arr[25];
int pos[25];
bool choice[25];
int getScore(){
	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(choice[m]){
				if(isNotOK(pos[j], arr[i])){
					cnt ++;
					break;
				}
			}
		}
	}
	return cnt;
}

int dfs(int pos = 0, int cnt = 0){
	if(pos == n){
		if(getScore() == maxScore) return cnt;
		return 0;
	}
	choice[pos] = false;
	const int res1 = dfs(pos + 1, cnt + 1);
	choice[pos] = true;
	const int res2 = dfs(pos + 1, cnt + 1);
	choice[pos] = false;
	return max(res1, res2);
}
int main()
{
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int t;
	scanf("%d", &t);
	for(int k = 0; k < t; k++){
		int length;
		scanf("%d %d %d %d", &n, &m, &length, &limit);
		for(int i = 0; i < n; i++){
			scanf("%d %d %d", &arr[i].startPos, &arr[i].speed, &arr[i].plusSpeed);
		}
		for(int i = 0; i < m; i++){
			scanf("%d", &pos[i]);
			choice[i] = true;
		}
		maxScore = getScore();
		printf("%d %d\n", maxScore, dfs());
	}
	
	return 0;
}